import {action, makeAutoObservable} from "mobx";
import {getCurrentSystemService, getCurrentSystemSetting, SystemServiceSetting} from "../apis/SystemServiceApi";
import {StringIdAndName} from "../types/BasicModels";

export class SystemServiceStore {

    systemService?: StringIdAndName

    systemServiceSetting?: SystemServiceSetting

    constructor() {
        makeAutoObservable(this)
    }

    setSystemService(data: StringIdAndName) {
        this.systemService = data
    }

    setSystemServiceSetting(systemServiceSetting: SystemServiceSetting) {
        this.systemServiceSetting = systemServiceSetting
    }

    async initFromClient() {
        let a = await getCurrentSystemService()
        this.setSystemService(a.data)
        let b = await getCurrentSystemSetting()
        this.setSystemServiceSetting(b.data)
    }
}

export const systemServiceStore = new SystemServiceStore()